/*
 * Copyright 2021 NXP
 * SPDX-License-Identifier: MIT
 */

#include "lvgl.h"
#include <stdio.h>
#include "gui_guider.h"
#include "events_init.h"

static lv_obj_t * screen_spinbox_1;
static void lv_screen_spinbox_1_increment_event_cb(lv_obj_t * screen_spinbox_1_btn, lv_event_t event)
{
	if(event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT){
	lv_spinbox_increment(screen_spinbox_1);
	}
}
static void lv_screen_spinbox_1_decrement_event_cb(lv_obj_t * screen_spinbox_1_btn, lv_event_t event)
{
	if(event == LV_EVENT_SHORT_CLICKED || event == LV_EVENT_LONG_PRESSED_REPEAT){
	lv_spinbox_decrement(screen_spinbox_1);
	}
}

void setup_scr_screen(lv_ui *ui){

	//Write codes screen
	ui->screen = lv_obj_create(NULL, NULL);

	//Write codes screen_cont_1
	ui->screen_cont_1 = lv_cont_create(ui->screen, NULL);

	//Write style LV_CONT_PART_MAIN for screen_cont_1
	static lv_style_t style_screen_cont_1_main;
	lv_style_init(&style_screen_cont_1_main);

	//Write style state: LV_STATE_DEFAULT for style_screen_cont_1_main
	lv_style_set_radius(&style_screen_cont_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_bg_color(&style_screen_cont_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_screen_cont_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_screen_cont_1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_cont_1_main, LV_STATE_DEFAULT, 255);
	lv_style_set_border_color(&style_screen_cont_1_main, LV_STATE_DEFAULT, lv_color_make(0x99, 0x99, 0x99));
	lv_style_set_border_width(&style_screen_cont_1_main, LV_STATE_DEFAULT, 1);
	lv_style_set_border_opa(&style_screen_cont_1_main, LV_STATE_DEFAULT, 255);
	lv_style_set_pad_left(&style_screen_cont_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_right(&style_screen_cont_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_cont_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_bottom(&style_screen_cont_1_main, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->screen_cont_1, LV_CONT_PART_MAIN, &style_screen_cont_1_main);
	lv_obj_set_pos(ui->screen_cont_1, 0, 0);
	lv_obj_set_size(ui->screen_cont_1, 320, 240);
	lv_obj_set_click(ui->screen_cont_1, false);
	lv_cont_set_layout(ui->screen_cont_1, LV_LAYOUT_OFF);
	lv_cont_set_fit(ui->screen_cont_1, LV_FIT_NONE);

	//Write codes screen_label_1
	ui->screen_label_1 = lv_label_create(ui->screen, NULL);
	lv_label_set_text(ui->screen_label_1, "专注嵌入式物联网相关技术");
	lv_label_set_long_mode(ui->screen_label_1, LV_LABEL_LONG_BREAK);
	lv_label_set_align(ui->screen_label_1, LV_LABEL_ALIGN_CENTER);

	//Write style LV_LABEL_PART_MAIN for screen_label_1
	static lv_style_t style_screen_label_1_main;
	lv_style_init(&style_screen_label_1_main);

	//Write style state: LV_STATE_DEFAULT for style_screen_label_1_main
	lv_style_set_radius(&style_screen_label_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_bg_color(&style_screen_label_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_screen_label_1_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_screen_label_1_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_label_1_main, LV_STATE_DEFAULT, 255);
	lv_style_set_text_color(&style_screen_label_1_main, LV_STATE_DEFAULT, lv_color_make(0x00, 0xaa, 0xff));
	lv_style_set_text_font(&style_screen_label_1_main, LV_STATE_DEFAULT, &lv_font_simsun_18);
	lv_style_set_text_letter_space(&style_screen_label_1_main, LV_STATE_DEFAULT, 2);
	lv_style_set_pad_left(&style_screen_label_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_right(&style_screen_label_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_label_1_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_bottom(&style_screen_label_1_main, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->screen_label_1, LV_LABEL_PART_MAIN, &style_screen_label_1_main);
	lv_obj_set_pos(ui->screen_label_1, 24, 25);
	lv_obj_set_size(ui->screen_label_1, 140, 0);

	//Write codes screen_label_2
	ui->screen_label_2 = lv_label_create(ui->screen, NULL);
	lv_label_set_text(ui->screen_label_2, "我是老温，一名热爱学习的嵌入式工程师");
	lv_label_set_long_mode(ui->screen_label_2, LV_LABEL_LONG_BREAK);
	lv_label_set_align(ui->screen_label_2, LV_LABEL_ALIGN_LEFT);

	//Write style LV_LABEL_PART_MAIN for screen_label_2
	static lv_style_t style_screen_label_2_main;
	lv_style_init(&style_screen_label_2_main);

	//Write style state: LV_STATE_DEFAULT for style_screen_label_2_main
	lv_style_set_radius(&style_screen_label_2_main, LV_STATE_DEFAULT, 0);
	lv_style_set_bg_color(&style_screen_label_2_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_screen_label_2_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_screen_label_2_main, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_label_2_main, LV_STATE_DEFAULT, 255);
	lv_style_set_text_color(&style_screen_label_2_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xae, 0x00));
	lv_style_set_text_font(&style_screen_label_2_main, LV_STATE_DEFAULT, &lv_font_simsun_13);
	lv_style_set_text_letter_space(&style_screen_label_2_main, LV_STATE_DEFAULT, 2);
	lv_style_set_pad_left(&style_screen_label_2_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_right(&style_screen_label_2_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_label_2_main, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_bottom(&style_screen_label_2_main, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->screen_label_2, LV_LABEL_PART_MAIN, &style_screen_label_2_main);
	lv_obj_set_pos(ui->screen_label_2, 20, 178);
	lv_obj_set_size(ui->screen_label_2, 273, 0);

	//Write codes screen_img_2
	ui->screen_img_2 = lv_img_create(ui->screen, NULL);

	//Write style LV_IMG_PART_MAIN for screen_img_2
	static lv_style_t style_screen_img_2_main;
	lv_style_init(&style_screen_img_2_main);

	//Write style state: LV_STATE_DEFAULT for style_screen_img_2_main
	lv_style_set_image_recolor(&style_screen_img_2_main, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_image_recolor_opa(&style_screen_img_2_main, LV_STATE_DEFAULT, 0);
	lv_style_set_image_opa(&style_screen_img_2_main, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->screen_img_2, LV_IMG_PART_MAIN, &style_screen_img_2_main);
	lv_obj_set_pos(ui->screen_img_2, 194, 14);
	lv_obj_set_size(ui->screen_img_2, 100, 140);
	lv_obj_set_click(ui->screen_img_2, true);
	//lv_img_set_src(ui->screen_img_2,&_qr_code_100x140);
	lv_img_set_src(ui->screen_img_2,&qr_code);
	lv_img_set_pivot(ui->screen_img_2, 0,0);
	lv_img_set_angle(ui->screen_img_2, 0);

	//Write codes screen_bar_1
	ui->screen_bar_1 = lv_bar_create(ui->screen, NULL);

	//Write style LV_BAR_PART_BG for screen_bar_1
	static lv_style_t style_screen_bar_1_bg;
	lv_style_init(&style_screen_bar_1_bg);

	//Write style state: LV_STATE_DEFAULT for style_screen_bar_1_bg
	lv_style_set_radius(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 10);
	lv_style_set_bg_color(&style_screen_bar_1_bg, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_bg_grad_color(&style_screen_bar_1_bg, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_bg_grad_dir(&style_screen_bar_1_bg, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 255);
	lv_style_set_pad_left(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_right(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_bottom(&style_screen_bar_1_bg, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->screen_bar_1, LV_BAR_PART_BG, &style_screen_bar_1_bg);

	//Write style LV_BAR_PART_INDIC for screen_bar_1
	static lv_style_t style_screen_bar_1_indic;
	lv_style_init(&style_screen_bar_1_indic);

	//Write style state: LV_STATE_DEFAULT for style_screen_bar_1_indic
	lv_style_set_radius(&style_screen_bar_1_indic, LV_STATE_DEFAULT, 10);
	lv_style_set_bg_color(&style_screen_bar_1_indic, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_color(&style_screen_bar_1_indic, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_dir(&style_screen_bar_1_indic, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_bar_1_indic, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->screen_bar_1, LV_BAR_PART_INDIC, &style_screen_bar_1_indic);
	lv_obj_set_pos(ui->screen_bar_1, 20, 84);
	lv_obj_set_size(ui->screen_bar_1, 150, 20);
	lv_bar_set_anim_time(ui->screen_bar_1,1000);
	lv_bar_set_value(ui->screen_bar_1,50,LV_ANIM_OFF);
	lv_bar_set_range(ui->screen_bar_1,0,100);

	//Write codes screen_slider_1
	ui->screen_slider_1 = lv_slider_create(ui->screen, NULL);

	//Write style LV_SLIDER_PART_INDIC for screen_slider_1
	static lv_style_t style_screen_slider_1_indic;
	lv_style_init(&style_screen_slider_1_indic);

	//Write style state: LV_STATE_DEFAULT for style_screen_slider_1_indic
	lv_style_set_radius(&style_screen_slider_1_indic, LV_STATE_DEFAULT, 50);
	lv_style_set_bg_color(&style_screen_slider_1_indic, LV_STATE_DEFAULT, lv_color_make(0x02, 0xa2, 0xb1));
	lv_style_set_bg_grad_color(&style_screen_slider_1_indic, LV_STATE_DEFAULT, lv_color_make(0x02, 0xa2, 0xb1));
	lv_style_set_bg_grad_dir(&style_screen_slider_1_indic, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_slider_1_indic, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->screen_slider_1, LV_SLIDER_PART_INDIC, &style_screen_slider_1_indic);

	//Write style LV_SLIDER_PART_BG for screen_slider_1
	static lv_style_t style_screen_slider_1_bg;
	lv_style_init(&style_screen_slider_1_bg);

	//Write style state: LV_STATE_DEFAULT for style_screen_slider_1_bg
	lv_style_set_radius(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 50);
	lv_style_set_bg_color(&style_screen_slider_1_bg, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_bg_grad_color(&style_screen_slider_1_bg, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_bg_grad_dir(&style_screen_slider_1_bg, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 255);
	lv_style_set_outline_color(&style_screen_slider_1_bg, LV_STATE_DEFAULT, lv_color_make(0xd4, 0xd7, 0xd9));
	lv_style_set_outline_opa(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_left(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_right(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_bottom(&style_screen_slider_1_bg, LV_STATE_DEFAULT, 0);
	lv_obj_add_style(ui->screen_slider_1, LV_SLIDER_PART_BG, &style_screen_slider_1_bg);

	//Write style LV_SLIDER_PART_KNOB for screen_slider_1
	static lv_style_t style_screen_slider_1_knob;
	lv_style_init(&style_screen_slider_1_knob);

	//Write style state: LV_STATE_DEFAULT for style_screen_slider_1_knob
	lv_style_set_radius(&style_screen_slider_1_knob, LV_STATE_DEFAULT, 50);
	lv_style_set_bg_color(&style_screen_slider_1_knob, LV_STATE_DEFAULT, lv_color_make(0x02, 0xa2, 0xb1));
	lv_style_set_bg_grad_color(&style_screen_slider_1_knob, LV_STATE_DEFAULT, lv_color_make(0x02, 0xa2, 0xb1));
	lv_style_set_bg_grad_dir(&style_screen_slider_1_knob, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_slider_1_knob, LV_STATE_DEFAULT, 255);
	lv_obj_add_style(ui->screen_slider_1, LV_SLIDER_PART_KNOB, &style_screen_slider_1_knob);
	lv_obj_set_pos(ui->screen_slider_1, 22, 210);
	lv_obj_set_size(ui->screen_slider_1, 265, 10);
	lv_slider_set_range(ui->screen_slider_1,0, 100);
	lv_slider_set_value(ui->screen_slider_1,50,false);

	//Write codes screen_spinbox_1
	ui->screen_spinbox_1 = lv_spinbox_create(ui->screen, NULL);

	//Write style LV_SPINBOX_PART_BG for screen_spinbox_1
	static lv_style_t style_screen_spinbox_1_bg;
	lv_style_init(&style_screen_spinbox_1_bg);

	//Write style state: LV_STATE_DEFAULT for style_screen_spinbox_1_bg
	lv_style_set_radius(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_bg_color(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 255);
	lv_style_set_border_color(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_border_width(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 2);
	lv_style_set_text_color(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, lv_color_make(0x00, 0x00, 0x00));
	lv_style_set_text_font(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, &lv_font_simsun_12);
	lv_style_set_text_letter_space(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_left(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 2);
	lv_style_set_pad_right(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 0);
	lv_style_set_pad_top(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 10);
	lv_style_set_pad_bottom(&style_screen_spinbox_1_bg, LV_STATE_DEFAULT, 10);
	lv_obj_add_style(ui->screen_spinbox_1, LV_SPINBOX_PART_BG, &style_screen_spinbox_1_bg);

	//Write style LV_SPINBOX_PART_CURSOR for screen_spinbox_1
	static lv_style_t style_screen_spinbox_1_cursor;
	lv_style_init(&style_screen_spinbox_1_cursor);

	//Write style state: LV_STATE_DEFAULT for style_screen_spinbox_1_cursor
	lv_style_set_bg_color(&style_screen_spinbox_1_cursor, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_color(&style_screen_spinbox_1_cursor, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_bg_grad_dir(&style_screen_spinbox_1_cursor, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_spinbox_1_cursor, LV_STATE_DEFAULT, 255);
	lv_style_set_text_font(&style_screen_spinbox_1_cursor, LV_STATE_DEFAULT, &lv_font_simsun_12);
	lv_obj_add_style(ui->screen_spinbox_1, LV_SPINBOX_PART_CURSOR, &style_screen_spinbox_1_cursor);

	//Write style LV_BTN_PART_MAIN for screen_spinbox_1
	static lv_style_t style_screen_spinbox_1_main_child;
	lv_style_init(&style_screen_spinbox_1_main_child);

	//Write style state: LV_STATE_DEFAULT for style_screen_spinbox_1_main_child
	lv_style_set_radius(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, 0);
	lv_style_set_bg_color(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_color(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, lv_color_make(0xff, 0xff, 0xff));
	lv_style_set_bg_grad_dir(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, LV_GRAD_DIR_VER);
	lv_style_set_bg_opa(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, 255);
	lv_style_set_border_color(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, lv_color_make(0x01, 0xa2, 0xb1));
	lv_style_set_border_width(&style_screen_spinbox_1_main_child, LV_STATE_DEFAULT, 2);
	lv_obj_set_pos(ui->screen_spinbox_1, 62, 129);
	lv_obj_set_width(ui->screen_spinbox_1, 80);
	lv_spinbox_set_digit_format(ui->screen_spinbox_1, 5, 3);
	lv_spinbox_step_prev(ui->screen_spinbox_1);
	lv_spinbox_set_range(ui->screen_spinbox_1, -99999, 99999);
	screen_spinbox_1 = ui->screen_spinbox_1;
	lv_coord_t screen_spinbox_1_h = lv_obj_get_height(ui->screen_spinbox_1);
	ui->screen_spinbox_1_btn = lv_btn_create(ui->screen, NULL);
	lv_obj_set_size(ui->screen_spinbox_1_btn, screen_spinbox_1_h, screen_spinbox_1_h);
	lv_obj_align(ui->screen_spinbox_1_btn, ui->screen_spinbox_1, LV_ALIGN_OUT_RIGHT_MID, 5, 0);
	lv_theme_apply(ui->screen_spinbox_1_btn, LV_THEME_SPINBOX_BTN);
	lv_obj_set_style_local_value_str(ui->screen_spinbox_1_btn, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_PLUS);
	lv_obj_set_event_cb(ui->screen_spinbox_1_btn, lv_screen_spinbox_1_increment_event_cb);
	ui->screen_spinbox_1_btn_minus = lv_btn_create(ui->screen, ui->screen_spinbox_1_btn);
	lv_obj_align(ui->screen_spinbox_1_btn_minus,ui->screen_spinbox_1, LV_ALIGN_OUT_LEFT_MID, -5, 0);
	lv_obj_set_event_cb(ui->screen_spinbox_1_btn_minus, lv_screen_spinbox_1_decrement_event_cb);
	lv_obj_set_style_local_value_str(ui->screen_spinbox_1_btn_minus, LV_BTN_PART_MAIN, LV_STATE_DEFAULT, LV_SYMBOL_MINUS);
	lv_obj_add_style(ui->screen_spinbox_1_btn, LV_BTN_PART_MAIN, &style_screen_spinbox_1_main_child);
	lv_obj_add_style(ui->screen_spinbox_1_btn_minus, LV_BTN_PART_MAIN, &style_screen_spinbox_1_main_child);
}